package com.xnyzc.lhy.common.penum.pay;

import com.xnyzc.lhy.common.entity.PEnum;
import com.xnyzc.lhy.common.penum.EErrorCode;

/**
 * 用户支付
 * 响应
 */
public enum EUserPayResultType implements PEnum<Integer>  {

    paySuccess(0, "支付成功"),
    insufficientSpace(1, "余额不足"),
    unLimit(2, "未开启额度"),
    deficiencyLimit(3, "额度不足"),
    unOrderNo(100, "非法的订单号"),
    unWallet(101, "未获取到用户钱包"),
    isNull(102, "钱数为null"),
    orderFailure(103, "更新订单失败"),
    orderNotCompleted(104, "订单未完成"),
    unUnpaidOrder(105, "此订单不是待支付订单"),
    unOrder(106, "未获取到订单"),
    unPaymentType(200, "未知支付类型"),
    unWeChat(300, "微信支付施工中"),
    unAlipay(301, "支付宝支付施工中"),
    payFailure(-1, "支付失败"),
    payFailureLimit(-2, "额度支付失败");

    private Integer value;
    private String desc;

    EUserPayResultType(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static EUserPayResultType findById(Integer value) {
        EUserPayResultType eUserPayResultType;
        switch (value) {
            case 0:
                eUserPayResultType = EUserPayResultType.paySuccess;
                break;
            case 1:
                eUserPayResultType = EUserPayResultType.insufficientSpace;
                break;
            case 2:
                eUserPayResultType = EUserPayResultType.unLimit;
                break;
            case 3:
                eUserPayResultType = EUserPayResultType.deficiencyLimit;
                break;
            case 100:
                eUserPayResultType = EUserPayResultType.unOrderNo;
                break;
            case 101:
                eUserPayResultType = EUserPayResultType.unWallet;
                break;
            case 102:
                eUserPayResultType = EUserPayResultType.isNull;
                break;
            case 103:
                eUserPayResultType = EUserPayResultType.orderFailure;
                break;
            case 104:
                eUserPayResultType = EUserPayResultType.orderNotCompleted;
                break;
            case 105:
                eUserPayResultType = EUserPayResultType.unUnpaidOrder;
                break;
            case 106:
                eUserPayResultType = EUserPayResultType.unOrder;
                break;
            case 200:
                eUserPayResultType = EUserPayResultType.unPaymentType;
                break;
            case 300:
                eUserPayResultType = EUserPayResultType.unWeChat;
                break;
            case 301:
                eUserPayResultType = EUserPayResultType.unAlipay;
                break;
            case -1:
                eUserPayResultType = EUserPayResultType.payFailure;
                break;
            default:
                throw new IllegalArgumentException("非法type");
        }
        return eUserPayResultType;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String toString() {
        return name();
    }

    @Override
    public String toChString() {
        return desc;
    }

    public String toMessage() {
        String errorMessage = this.value + "," + this.desc;
        return errorMessage;
    }
}
